<?php


include_once '../Model/Route.php';
include_once '../Model/GPS.php';
include_once '../AtacCommunicator/ACtraveltime.php';
include_once 'Constants.php';

class InfoRoute{
	
	function __construct() {
		 
	}


	function get_itinerari(){
		
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS); 
			mysql_select_db(DBNAME);
			if ($conn == FALSE)
			{
				return NULL;
			}
			$query = "SELECT * FROM itinerari";
			$result = mysql_query($query);
		   if ($result==FALSE)
				return NULL;
			$itinerari = array();
			
			while($row = mysql_fetch_array($result))
			{
				$itinerario = $row['itinerario'];
				$id = $row['ID'];
				$lat = $row['latitudine'];
				$long = $row['longitudine'];
				
				//$coord = new GPS($lat,$long); 		
				$route = new route($id, $itinerario, $lat,$long);
				array_push($itinerari,$route);
			
			}

			mysql_close($conn);
			return $itinerari;

		
		
		
		}
		
		
	function get_archi($id){
		
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS); 
			mysql_select_db(DBNAME);
			if ($conn == FALSE)
			{
				return NULL;
			}
			$query = "select * from archiatac where da = $id";
			$result = mysql_query($query);
		   if ($result==FALSE)
				return NULL;
			
			
			while($row = mysql_fetch_array($result))
			{
				$from = $row['da'];
				$to = $row['a'];
				$link = $row['link'];
				$archi[]= array($from,$to,$link);
						
			}

			mysql_close($conn);
			return $archi;

		
		}
		
		function get_itwhithid($id_to){
			
			$conn = mysql_connect(DBHOST, DBUSER, DBPASS); 
			mysql_select_db(DBNAME);
			if ($conn == FALSE)
			{
				return NULL;
			}
			$query = "SELECT * FROM itinerari where ID=$id_to";
			$result = mysql_query($query);
		   if ($result==FALSE)
				return NULL;
				$row = mysql_fetch_array($result);
				$itinerario = $row['itinerario'];
				$id = $row['ID'];
				$lat = $row['latitudine'];
				$long = $row['longitudine'];
				
				//$coord = new GPS($lat,$long); 		
				$route = new route($id, $itinerario, $lat,$long);

			mysql_close($conn);
			return $route;

			
			
			}

}



/*
	function getParkInformation($parkID) {

		$info = ""; 
		$conn = mysql_connect(DBHOST, DBUSER, DBPASS);

		if ($conn==FALSE)
			return $info;
		
		mysql_select_db(DBNAME);
		$query = "select * from ".PARKSTABLENAME." where idp='".$parkID."';";
		$result = mysql_query($query);
		
		if($result==null)
			return "";
		while($row = mysql_fetch_array($result))
		{
			$info = $row['idp'].InfoManager::$INFOSEPARATOR.$row['nome'].InfoManager::$INFOSEPARATOR.$row['via'].InfoManager::$INFOSEPARATOR.$row['posti'].InfoManager::$INFOSEPARATOR.$row['lat'].InfoManager::$INFOSEPARATOR.$row['long'];
		}
		
		mysql_close($conn);
		
		return $info;

	
	}	
	
*/	
	
	
	

?>